home *** CD-ROM | disk | FTP | other *** search
/ Aminet 51 / Aminet 51 (2002)(GTI - Schatztruhe)[!][Oct 2002].iso / Aminet / util / arc / xadmasterdev.lha / xad / Include / Autodocs / xadsub.doc < prev   
Encoding:
Text File  |  2002-08-20  |  19.0 KB  |  407 lines

  1. TABLE OF CONTENTS
  2.  
  3. xadForeman/--Overview--
  4. xadClient/--Overview--
  5. xadClient/xcFree
  6. xadClient/xcGetInfo
  7. xadClient/xcRecogData
  8. xadClient/xcUnArchive
  9.  
  10. VERSION
  11.         $VER: xadsub.doc 12.0 (15.06.2002) by SDI
  12.  
  13. xadForeman/--Overview--                               xadForeman/--Overview--
  14.  
  15. The xadForeman structure is just some kind of header for external clients.
  16. It protects the clients from being executed accidentally by having a small
  17. piece of code (MOVEQ #-1,d0 : RTS) in the first 4 bytes.
  18. The master can identify a valid bunch of external clients by checking the
  19. first hunk of a file for the foreman identification.
  20. Finally, a foreman holds the pointer to a linked list of clients and thus
  21. enables the master to work with these clients.
  22. The version entry of this structure specifies name and version of the file
  23. and not of the linked client list!
  24.  
  25. Multiple clients can be stored in the linked list of one file. This allows
  26. to use code by different clients. E.g. The normal archive and a SFX client
  27. both use nearly equal unarchiving code, but different recognition functions.
  28.  
  29. If the clients have no double useable code, it is better to distribute them
  30. in seperate files to allow better updating.
  31.  
  32. xadClient/--Overview--                                 xadClient/--Overview--
  33.  
  34. The xadClient structure is the heart of the whole library system. Each
  35. client enables the master to recognize and unarchive files.
  36.  
  37. Therefore each client contains 4 routines that are called from the master.
  38. Pointers to these are stored in xc_RecogData, xc_GetInfo, xc_UnArchive and
  39. xc_Free.
  40.  
  41. All routines have one thing in common: the CPU registers D0/D1/A0/A1 are
  42. so-called scratch registers, they may change during execution, all other
  43. registers must remain unchanged. CPU register A6 holds a pointer to the
  44. xadMasterBase structure. See chapters below for a description of the client
  45. routines.
  46.  
  47. ALL CLIENT ROUTINES MUST BE REENTRANT! NEVER STORE ANY DATA IN STATIC
  48. MEMORY AREAS, USE THE STACK OR SOME ALLOCATED MEMORY INSTEAD! REMEMBER THAT
  49. THE ROUTINES MIGHT BE CALLED BY SEVERAL PROGRAMS AT THE SAME TIME! DO
  50. NOT EXCEED STACK USAGE (1KB SHOULD BE THE MAXIMUM), AS PROGRAMS NORMALLY
  51. HAVE ONLY 4KB STACK.
  52.  
  53. The name of the archiver that is supported by the client and the flags that
  54. describe the packer are stored in xc_ArchiverName and xc_Flags. Internal
  55. clients all have an unique ID value stored in xc_Identifier. If you have
  56. written a client that should replace an internal one, because it is faster
  57. or otherwise enhanced, simply put the ID of the client to be replaced in
  58. xc_Identifier. The old client will then be taken out of the list of used
  59. clients. Normally this ID should be zero. There is one problem with this:
  60. When the user deactivates external clients the xadmaster system is missing
  61. this type completely as internal client is not activated in this case.
  62.  
  63. xcRecogData() usually only requires a quite small part of a file to
  64. recognize it properly. To avoid reading the whole file for recognition
  65. purposes, you need to set xc_RecogSize to the minimum amount of bytes
  66. that is required to recognize the crunched file correctly.
  67. Note that xadmaster uses this value internally to decide whether a file
  68. might be archived with a archiver or not, so you don't have to do an extra
  69. size comparison in your xc_RecogData function any more.
  70. For archiver headers with non-constant sizes, simply set xc_RecogSize
  71. to a value that will ensure correct recognition of all possible files.
  72.  
  73. Whenever you intend to use features of the xadmaster.library in your
  74. clients that are marked (V2) or higher, make sure to set xc_MasterVersion
  75. to the desired version number, otherwise an old library version might
  76. crash while using the new client.
  77.  
  78. Whenever a client calls a xadmaster function and gets a return code, the
  79. client needs to return this code! So whenever an error code is produced
  80. somewhere, it must reach the calling program. This is most important
  81. for progress report (automatically called by xadHookAccess), as the
  82. XADERR_SKIP can be checked by calling program.
  83.  
  84. ANY needed structure must be allocated with xadAllocObject! None of the
  85. XAD structures can be allocated any other way!
  86.  
  87. Multivolume support:
  88. This system also supports multivolume archives. A special multivolume
  89. input stream (XAD_INSPLITTED) allows to pass multiple input files as
  90. one stream to the clients. This means multivolume archiver files are
  91. passed as ONE stream to the related client. The client may check the
  92. ai->xai_MultiVolume entry. This is an ULONG array witch holds the start
  93. offset of every part and is finished with an zero value. Note that the
  94. first entry is a zero value as well in normal case. The client may
  95. expect the parts to be in correct order, but must handle missing or
  96. defective parts (Handling of defective archives is necessary for normal
  97. archives as well!). Do not rely to much on part size information, as
  98. missing parts or defective parts normally will destroy the usefulness
  99. of that size information.
  100.  
  101. Filesystem clients:
  102. Starting with (V5), the library supports external filesystem clients as
  103. well. These clients have no xc_RecogData function, but get called xc_GetInfo
  104. always. The fields xc_RecogSize is useless as well for these clients.
  105. Filesystem clients are called, when xadGetDiskInfo() and xadDiskFileUnArc()
  106. are called. They are skipped for xadGetInfo(). The functions are equal
  107. to normal clients, except that they handle filesystem images and no
  108. file archives.
  109.  
  110. Apple Macintosh support:
  111. When handling special Apple archives, handle data and resource fork as
  112. separate entries into xadFileInfo list, with some additional information.
  113.  
  114. The flag XADFIF_MACDATA flag implies:
  115. - This file IS a data fork.
  116. - This file CAN have a separate resource fork.
  117. - This file's xfi_Comment (if not NULL) can be read as "TYPE/CRTR" or
  118.   "TYPE/CRTR FLGS", where TYPE and CRTR are 4 character ASCII codes
  119.   detailing a file's file ID and creator ID, and FLGS is a 4 digit
  120.   hexadecimal number detailing Finder Flags, as defined by the field
  121.   'FInfo.fdFlags' in RFC 1740.
  122.   Any normal comment may be appended at the end seperated by a space
  123.   character. Use "????/???? 0000" as default in case the data is not
  124.   available, but a comment needs to be stored.
  125. - The entry xfi_MacFork is either NULL or a pointer to the resource fork
  126.   list entry.
  127.  
  128. The flag XADFIF_MACRESOURCE flag implies:
  129. - This file IS a resource fork.
  130. - Suggested filename is "<datafork name>.rsrc".
  131. - This file DOES have a separate data fork.
  132. - The entry xfi_MacFork is a pointer to the data fork list entry.
  133. - If the data fork is empty, do not create an entry for it, but
  134.   leave xfi_MacFork empty and store the comment in resource fork entry.
  135.  
  136. NOTE: The pointer xfi_MacFork points to a normal entry of the file
  137. information list! This pointer is only additional information to find
  138. corresponding entries.
  139.  
  140. Specials support:
  141. Starting with (V11) the xadFileInfo structure has an additional xadSpecial
  142. field, which is a linked list of special structures. These can be used
  143. to store additional information. Currently this is defined for UNIX 
  144. devices and Amiga address crunchers. This special structure is defined
  145. as "union". The field xfis_Type is used to determine, which structure
  146. is really used. That method was choosen to be flexible without removing
  147. the advantages of C programming languages.
  148.  
  149. Also the xfi_FileType field is used to supply additional information about
  150. the type of the file. This can be useful for extractor programs knowing how
  151. to handle special filetypes.
  152.  
  153. xadClient/xcFree                                             xadClient/xcFree
  154.  
  155.    NAME
  156.         xcFree -- Free all resources allocated by xcGetInfo
  157.  
  158.    SYNOPSIS
  159.         xcFree(ai, xadMasterBase)
  160.                A0       A6
  161.  
  162.         void xcFree(struct xadArchiveInfo *, struct xadMasterBase *)
  163.  
  164.    FUNCTION
  165.         This function frees all the stuff allocated by xcGetInfo. It is
  166.         called after unsuccessful xcGetInfo as well (except for filesystem
  167.         clients returning XADERR_FILESYSTEM), so you need not to call any
  168.         freeing functions there. But be prepared for that case. You must
  169.         check all entries, as xcGetInfo may fail in the first allocation
  170.         stages (f.e. allocation of xadDiskInfo or xadFileInfo structures).
  171.         Clear all entries you have freed! There should not be any pointers
  172.         left in xadArchiveInfo structure which do not point to valid
  173.         memory.
  174.  
  175.         Starting with (V2) the master library can do some stuff for you.
  176.         This is always done after calling this function, so you have the
  177.         chance to do private stuff before!
  178.         If you set the flag XADCF_FREEFILEINFO in xc_Flags, the master
  179.         library parses the xai_FileInfo list and frees every entry.
  180.         If you set the flag XADCF_FREEDISKINFO in xc_Flags, the master
  181.         library parses the xai_DiskInfo list and frees every entry.
  182.         If you set the flag XADCF_FREETEXTINFO in xc_Flags, the master
  183.         library parses the xdi_TextInfo list of every xadDiskInfo
  184.         structure and frees every entry.
  185.         If you set the flag XADCF_FREETEXTINFOTEXT in xc_Flags, the
  186.         master library frees xti_Text entry of xadTextInfo structures.
  187.         This requires these entries to be allocated with xadAllocVec()
  188.         function.
  189.         If you set the flag XADCF_FREESKIPINFO with (V3) in xc_Flags, the
  190.         master library parses the xai_SkipInfo list and frees every entry.
  191.         If you set the flag XADCF_FREEPECIALINFO with (V11) in xc_Flags, the
  192.         master library parses the xfi_SpecialInfo list and frees every entry.
  193.         If you set the flag XADCF_FREEXADSTRINGS with (V12) in xc_Flags, the
  194.         master library parses the xadFileInfo structures and frees every
  195.         entry, which is marked as XAD string.
  196.  
  197.         If your free function is empty, because all can be done by master
  198.         library, then you may place a zero in xc_Free field of xadClient
  199.         structure and remove the function totally.
  200.  
  201.    INPUTS
  202.         ai      the master communication structure
  203.  
  204.    SEE ALSO
  205.         Example sourcecodes, xadmaster.library/xadFreeInfo()
  206.  
  207. xadClient/xcGetInfo                                       xadClient/xcGetInfo
  208.  
  209.    NAME
  210.         xcGetInfo -- create all information about an archive file
  211.  
  212.    SYNOPSIS
  213.         result = xcGetInfo(ai, xadMasterBase)
  214.           D0               A0        A6
  215.  
  216.         LONG xcGetInfo(struct xadArchiveInfo *, struct xadMasterBase *)
  217.  
  218.    FUNCTION
  219.         This function is the most important one. It creates a structure
  220.         list containing all necessary information. File archivers create
  221.         a linked list of xadFileInfo structures for every file/link/
  222.         directory which is stored in the archive. xadAllocObject helps
  223.         to store that information by providing 3 tags for getting special
  224.         memory. XAD_OBJNAMESIZE can be used to allocate a buffer for
  225.         storing (also multiple) names. The buffer is byte aligned. Do not
  226.         forget to count the 0-byte for every string you want to store there.
  227.         The buffer pointer is stored in xfi_FileName.
  228.         XAD_OBJCOMMENTSIZE is equal to this, but stored in xfi_Comment.
  229.         For file and disk archives there is the flag XAD_OBJPRIVINFOSIZE,
  230.         which returns a longword aligned buffer in xfi_PrivateInfo or
  231.         xdi_PrivateInfo.
  232.         Disk archivers create a linked list of xadDiskInfo structures.
  233.         Normal disk archivers do not allow to store more than one archive,
  234.         so linking is most time not necessary, but it is supported.
  235.         When storing information texts, they must be finished with a zero
  236.         byte, which is not counted in size field!
  237.  
  238.     Starting with (V12) a new handling of filename, comment and linkname
  239.     is possible. The function xadGetFilename() can be used the convert the
  240.     names from different charsets and encodings and create and allocate
  241.     an XAD string. When using this the flags XADFIF_XADSTRFILENAME,
  242.     XADFIF_XADSTRLINKNAME and XADFIF_XADSTRCOMMENT need to be set and it
  243.     makes no sense to use the XAD_OBJ...SIZE tags with the structure
  244.     allocation. If the client structure has XADCF_FREEXADSTRINGS set,
  245.     these strings are freed automatically later.
  246.     Always use this method instead of doing own conversions, as the XAD
  247.     strings are loseless (by using unicode internally). The destination
  248.     type for xadGetFilename() must be CHARSET_HOST always!
  249.  
  250.         Every file or disk entry gets an entrynumber, which must be unique.
  251.         The number for each entry must be exactly the same, if the archive
  252.         is reopened.
  253.         Most disk archivers are based on cylinder structure. These should
  254.         fill the xadDiskInfo fields correctly. If archivers are not based
  255.         on it (e.g. only sector based) they need to set XADDIF_NOCYLINDER
  256.         flag!
  257.         Starting with (V10) the functions xadAddFileEntry() and
  258.         xadAddDiskEntry() should be used to insert a new entry into the linked
  259.         list. This allows to use progress hooks and automatically sets correct
  260.         entry number. Always use the return value, as it may be XADERR_BREAK,
  261.         if user stopped processing! If possible the EXTRACTONBUILD flags can
  262.         be set and the entry maybe extracted directly after adding it. The
  263.         XAD_SETINPOS flag is useful to get correct file position in any case.
  264.  
  265.         If the archiver format does not support file dates, set the
  266.         current date (XAD_DATECURRENTTIME tag) and XADFIF_NODATE flag.
  267.         Protection bits default to zero (equals "rwed").
  268.         Archivers may store XADAIF_FILECORRUPT flag in xai_Flags, when 
  269.         archive is corrupt, but some entries are still usable. Unusable
  270.         entries must not appear in entry list. Do not return an error
  271.         code in that case, as an error code always means total failure.
  272.         Starting with V2, an error code may be stored in xai_LastError,
  273.         when XADAIF_FILECORRUPT is used.
  274.  
  275.         Starting with (V3), you may produce a linked list of xadSkipInfo
  276.         structures. The entries must not overlap and there must be at
  277.         least one byte between entries!
  278.         This forces the xadHookTagAccess() function to skip these parts
  279.         for read, copy and input seek operations, when XAD_USESKIPINFO
  280.         tag is used.
  281.  
  282.     The system can handle single crunched files also. These are handled
  283.     as if they where file archives. Set XADFIF_NOFILENAME or
  284.     XADFIF_NOUNCRUNCHSIZE if necessary. In case you set
  285.     XADFIF_NOFILENAME, you should store xadMasterBase->xmb_DefaultName
  286.     as filename. Starting with V7 the master library supplies the
  287.     input name in xai_InName (only if available). This can be used for
  288.     name creation also. You need to allocate name space and copy (and
  289.     modify) that name, as the pointer does not stay valid after leaving
  290.     xcGetInfo().
  291.  
  292.     Filesystem clients need to return XADERR_FILESYSTEM, if the type
  293.     is totally unknown. Else they will break the scanning for other
  294.     filesystems. Do not return any other return codes (except produced
  295.     by low memory or input errors), before you have validated the file
  296.     type.
  297.     NOTE: When XADERR_FILESYSTEM is returned, you may not allocate any
  298.     stuff or change any pointers or entries in the archiveinfo structure.
  299.     Especially the xcFree() functions is not called in this case! If
  300.     you do any allocations, so free them before leaving the function
  301.     with XADERR_FILESYSTEM.
  302.  
  303.    INPUTS
  304.         ai      master communication structure
  305.  
  306.    RESULT
  307.         result  - any of the XADERR codes or zero when all is ok.
  308.  
  309.    SEE ALSO
  310.         Example sourcecodes, xadmaster.library/xadGetInfo(),
  311.         xadmaster.library/xadHookTagAccess(),
  312.         xadmaster.library/xadHookAccess(), xadmaster.library/xadGetFilename(),
  313.         xadmaster.library/xadAddFileEntry(),
  314.         xadmaster.library/xadAddDiskEntry()
  315.  
  316. xadClient/xcRecogData                                   xadClient/xcRecogData
  317.  
  318.    NAME
  319.         xcRecogData -- Scan input buffer for known archiver type
  320.  
  321.    SYNOPSIS
  322.         result = xcRecogData(size, buffer, xadMasterBase)
  323.           D0                  D0     A0         A6
  324.  
  325.         BOOL xcRecogData(ULONG, STRPTR, struct xadMasterBase *)
  326.  
  327.    FUNCTION
  328.         Returns non zero when this buffer is part of a archive file
  329.         supported by this client. The recognition should be very stable.
  330.         It should be tested with lots of files. One wrong recognition
  331.         for 100000 files is acceptable.
  332.  
  333.     The minimum size needed for recognition (stored in xadClient
  334.     structure) should not be larger than 1024 bytes if possible.
  335.     Remember, that the master library needs to allocate recognition
  336.     buffers with largest size found in all clients. Scanning archives
  337.     is slowed down, if this size is too large!
  338.  
  339.     This function does not exists for filesystem clients (set its pointer
  340.     to 0).
  341.  
  342.     If you set XADCF_NOCHECKSIZE in client structure, this function is
  343.     also called for buffers shorter than the minimum size specified in
  344.     client structure. This is useful for archiver formats, which have
  345.     different sizes and hard detection schemes (e.g. EXE and SFX types).
  346.     You need to do minimum checks yourself: The minimum passed size may
  347.     be zero (empty file!). Do not read behind buffer borders in any case.
  348.  
  349.    INPUTS
  350.         size    size of passed buffer
  351.         buffer  buffer containing start of file to scan
  352.  
  353.    RESULT
  354.         result - TRUE if archiver is recogniced, FALSE if not
  355.  
  356.    SEE ALSO
  357.         Example sourcecodes, xadmaster.library/xadRecogFile(),
  358.         xadmaster.library/xadGetInfo()
  359.  
  360. xadClient/xcUnArchive                                   xadClient/xcUnArchive
  361.  
  362.    NAME
  363.         xcUnArchive -- write the required entry to destination
  364.  
  365.    SYNOPSIS
  366.         result = xcUnArchive(ai, xadMasterBase)
  367.           D0                 A0        A6
  368.  
  369.         LONG xcUnArchive(struct xadArchiveInfo *, struct xadMasterBase *)
  370.  
  371.    FUNCTION
  372.         This function dearchives one entry. The required entry is passed
  373.         in xai_CurFile or xai_CurDisk. A normal client will support only
  374.         one of the two possibilities, but clients using file and/or disk
  375.         archives are allowed as well. When writing disk data, the client
  376.         should write data in blocks with size of multiple sectorsize.
  377.         Although it should work, it is not recommended to write blocks
  378.         unequal to this.
  379.         Nearly all information you may need is stored in xadArchiveInfo
  380.         structure.
  381.         You may expect the entries to be unarchived in same order as they
  382.         are numbered, but it is not necessary! So be prepared to restart
  383.         decrunching for archivers using blocks or merge methods.
  384.         Disk archivers may expect to be called again to dearchive an
  385.         entry, even if there is only one! So restore the file position
  386.         you need to unarchive.
  387.  
  388.         When XADFIF_SEEKDATAPOS (file archive) or XADDIF_SEEKDATAPOS (disk
  389.         archive) is set, the master automatically seeks to the position in
  390.         xfi_DataPos or xdi_DataPos (V3).
  391.  
  392.         Starting with (V3), a linked list of xadSkipInfo structures
  393.         forces the xadHookTagAccess() function to skip these parts
  394.         for read, copy and input seek operations, when XAD_USESKIPINFO
  395.         tag is used.
  396.  
  397.    INPUTS
  398.         ai      master communication structure
  399.  
  400.    RESULT
  401.         result  - any of the XADERR codes or zero when all is ok.
  402.  
  403.    SEE ALSO
  404.         Example sourcecodes, xadmaster.library/xadDiskunArc(),
  405.         xadmaster.library/xadFileUnArc()
  406.  
  407.